//
//  LBContactListViewController.h
//  LBContactListViewController
//
//  Created by LINAICAI on 2017/12/6.
//

#import <LBUIKit/LBUIKit.h>
@class LBContactModel;

typedef NS_OPTIONS(NSUInteger, LBContactListViewMode) {
    LBContactListViewModeNomal = 1 << 0,//普通浏览模式
    LBContactListViewModeSingleSelect = 1 << 1,//单选模式
    LBContactListViewModeMultiSelect = 1 << 2,//多选模式
    LBContactListViewModeSelected = 1 << 3,//已选模式，已经选好的，再次进来会隐藏
};



///回调代理
@protocol LBContactListViewControllerDelegate <NSObject>
@optional
///改变选中联系人(用于非浏览模式下)
- (void)LBContactListViewControllerSelectChangeWithContact:(LBContactModel*)contact;
///点击某行(用于浏览模式下)
- (void)LBContactListViewControllerDidSelectWithContact:(LBContactModel*)contact;
///开始搜索联系人
- (void)LBContactListViewControllerDidBegainSearchContact;
///结束搜索联系人
- (void)LBContactListViewControllerDidEndSearchContact;
///每次搜索到的结果，返回联系人模型数组
- (void)LBContactListViewControllerSearchResultWithContacts:(NSArray<LBContactModel*> *)contacts;
///清空搜索联系人
- (void)LBContactListViewControllerCleanAllSearchContact;

@end

@interface LBContactListViewController : LBBaseViewController
///添加联系人的按钮
@property (nonatomic , strong , readonly)UIBarButtonItem *addContactBarButtonItem;
///联系人的列表
@property (nonatomic , strong , readonly)UITableView *tableView;
///搜索控件
@property (nonatomic , strong , readonly)UISearchBar *searchBar;
///传入的预选中的联系人(手机号码)
@property (nonatomic , strong , readonly)NSArray<NSString *> *numbers;
///当前选中的联系人(手机号码)
@property (nonatomic , strong , readonly)NSMutableArray<NSString *> *currentNumbers;
///模式
@property (nonatomic , assign , readonly)LBContactListViewMode mode;
///列表展示的数据源
@property (nonatomic , strong , readonly)NSMutableArray<NSMutableArray<LBContactModel*>*> *dataSources;
///服务端获取的远程数据
@property (nonatomic , strong , readonly)NSArray<LBContactModel *> *remoteDataSources;
///模糊搜索结果
@property (nonatomic , strong , readonly)NSArray<LBContactModel *> *searchResultDataSources;
///回调代理
@property (nonatomic , weak)id<LBContactListViewControllerDelegate> delegate;
///禁止构造方法
+ (instancetype)new NS_UNAVAILABLE;
- (instancetype)initWithCoder:(NSCoder *)coder NS_UNAVAILABLE;
- (instancetype)initWithNibName:(nullable NSString *)nibNameOrNil bundle:(nullable NSBundle *)nibBundleOrNil NS_UNAVAILABLE;
///构造函数
- (instancetype _Nullable )init NS_DESIGNATED_INITIALIZER;
- (instancetype _Nullable )initWithSelectMode:(LBContactListViewMode)selectMode NS_DESIGNATED_INITIALIZER;
///构造函数，需要传递选中的联系人id
- (instancetype _Nullable )initWithSelectMode:(LBContactListViewMode)selectMode numbers:(NSArray<NSString *> *_Nullable)numbers NS_DESIGNATED_INITIALIZER;
///获取所有当前的联系人
- (NSArray<LBContactModel*> *_Nullable)AllContacts;
///获取所有选中的联系人(LBContactListViewModeSelected模式下返回的选中的联系人不会包含传进去的)
- (NSArray<LBContactModel*> *_Nullable)AllSelectContacts;
///添加联系人方法
- (void)addContactClick:(id _Nonnull )sender;

@end
